package com.huaixia.cozeapi.config;

import com.huaixia.cozeapi.domain.CozeApi;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 读取 coze 配置
 * @author biliyu
 * @date 2024/6/25 13:52
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "coze")
public class CozeConfig {

    @ApiModelProperty("coze 请求地址")
    private String url;

    @ApiModelProperty("coze API 配置")
    private List<CozeApi> cozeApis;

    public Map<String, String> BotTokenMap() {
        Map<String, String> botTokenMap = new HashMap<>();
        for (CozeApi api : cozeApis) {
            for (String botId : api.getBotIds()) {
                botTokenMap.put(botId, api.getPersonalAccessToken());
            }
        }
        return botTokenMap;
    }

}
